// const API = "https://lxg.juyiyun.cn/v1/";
const API = "https://jzy.nuoche.la/v1/";



var get = (url, data, datatype) => {
    return new Promise((rev, rej) => {
        wx.request({
            url: url.indexOf('http') > -1 ? url : API + url,
            method: 'GET',
            data: data,
            // dataType:datatype,
            header: {
                'content-type': datatype ? datatype : 'application/x-www-form-urlencoded'
            },
            async: false,
            success: res => {
                rev(res.data);
            },
            fail: (error) => {
                rej(error)
            }
        })
    })
}
var post = (url, data, datatype) => {
    return new Promise((rev, rej) => {
        wx.request({
            url: url.indexOf('http') > -1 ? url : API + url,
            method: "POST",
            data: data,
            async:true,
            header: {
                'content-type': datatype ? datatype : 'application/x-www-form-urlencoded'
            },
            success: res => {
                rev(res.data);
            },
            fail: (error) => {
                rej(error)
            },
            complete(data){
            }
        })
    })
}
module.exports.sendGet = get;
module.exports.sendPost = post;